package com.syh.jn.scm.dto.downstream.purchase;

import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * Date:2018/7/3
 * Author:Clown
 * 下游采购单MTO;
 */
@Data
public class DownPurchaseOrderMto implements Serializable {
  /**
   * id
   */
  @NotNull(message = "id不能为空")
  private Long id;
  /**
   * 客户id
   */
  @NotNull(message = "客户id不能为空")
  private Long downStreamCompanyId;
  /**
   * 第三方订单号
   */
  private String extCode;
  /**
   * 收货人姓名
   */
  @NotNull(message = "收货人姓名不可为空")
  private String deliName;
  /**
   * 收货人联系电话
   */
  @NotNull(message = "收货人联系电话不可为空")
  private String deliTel;
  /**
   * 要求到货时间
   */
  private Long receiveTimestamp;
  /**
   * 收货地区编码
   */
  private String deliAreaCode;
  /**
   * 收货地址省市区
   */
  @NotNull(message = "收货地址省市区不能为空")
  private String deliArea;
  /**
   * 收货人详细地址
   */
  @NotNull(message = "收货人详细地址不能为空")
  private String deliAddress;
  /**
   * 订单备注
   */
  private String remark;
  /**
   * 采购订单项
   */
  @NotEmpty(message = "商品不能为空")
  private List<PurchaseOrderItemMTO> items;

  @Data
  public class PurchaseOrderItemMTO implements Serializable {
    /**
     * 商品id
     */
    @NotNull(message = "商品id不能为空")
    private Long goodsId;
    /**
     * 单价
     */
    @NotNull(message = "单价不能为空")
    @DecimalMin(value = "0", message = "商品单价必须大于0")
    private BigDecimal price;
    /**
     * 商品数量
     */
    @NotNull(message = "采购数量不能为空")
    @DecimalMin(value = "0", message = "采购数量必须大于0")
    private BigDecimal quantity;
    /**
     * 备注
     */
    @Length(max = 500, message = "备注最大长度为500")
    private String remark;
  }
}
